<template>
	<div class="marketingList">
		<group class="salesDataDiscoveryGroup">
			<div style="margin-top: 5px; margin-bottom: 5px; z-index: 999">
				<span style="font-weight: bold; font-size: 15px; padding-left: 5px">客户信息</span>
				<x-button @click.native="goBatch" style="padding: 0 0.5em;line-height: normal;" mini :gradients="['#FF2719', '#FF61AD']">批处理</x-button>
				<button-tab class="btnTab">
					<button-tab-item :selected="page === 'getNotAssignedCustomers'" @on-item-click="fetchData(0)">待分配</button-tab-item>
					<button-tab-item :selected="page === 'getObsoleteCustomers'" @on-item-click="fetchData(1)">回收站</button-tab-item>
				</button-tab>
			</div>
		</group>

		<div v-if="page == 'getNotAssignedCustomers'">
			<NotAssignedCustomer curURL="ai/sales/pages/getCustomerNotAssignedModel" :orderBy="orderBy" :sequence="sequence" :username="username" jumpToObjectDetails="customerDetails"></NotAssignedCustomer>
		</div>
		<div v-else-if="page == 'getObsoleteCustomers'">
			<ObsoleteCustomer curURL="customers/pages/getObsoleteCustomers" :orderBy="orderBy" :sequence="sequence" :username="username" jumpToObjectDetails="customerDetails" status="1"></ObsoleteCustomer>
		</div>

	</div>
</template>

<script>
	import bus from '@/event/eventBus'
	import NotAssignedCustomer from '../../../../components/mobile/scroller/scrollerNotAssignedCustomer'
	import ObsoleteCustomer from '../../../../components/mobile/scroller/scrollerObsoleteCustomerList'
	import {Group, Cell, XButton, Grid, GridItem, ButtonTab, ButtonTabItem} from 'vux'
	export default {
		name: "marketingList",
		components: {
			Group,
			Cell,
			XButton,
			Grid,
			GridItem,
			ObsoleteCustomer,
			NotAssignedCustomer,
			ButtonTab,
			ButtonTabItem
		},
		data() {
			return {
				title: '准客户总览',
				items: [],
				orderBy: 'days',
				sequence: 'asc',
				username: '',
				page: 'getNotAssignedCustomers'
			}
		},
		beforeRouteLeave(to, from, next){
			//存储当前页面信息
			this.$store.commit('CREATE_URL_PARAMS', {name: from.name, params: this.page})
			next()
		},
		created: function () {
			bus.$emit("userDefinedEvent", 2)
			bus.$emit("barController", 1)
			bus.$emit("setTopSimpleTitle", '市场名单总览')

			this.$store.commit('FETCH_URL_PARAMS')
			if(this.$store.state.user.urlParamsMap !=null && this.$store.state.user.urlParamsMap["marketingList"] != null){
				this.page = this.$store.state.user.urlParamsMap["marketingList"].params
			}else{
				this.page = 'getNotAssignedCustomers'
			}

			this.username = this.$store.state.user.userModel.sysUser.username
			if(sessionStorage.orderBy != null){
				this.orderBy = sessionStorage.orderBy
			}

			if(sessionStorage.sequence != null){
				this.sequence = sessionStorage.sequence
			}

		},
		methods: {
			goBatch: function () {
				this.$router.push('userListForBatch')
			},
			fetchData: function (value) {
				if(value == 1){
					this.page = 'getObsoleteCustomers'
				}else{
					this.page = 'getNotAssignedCustomers'
				}
			},
			orderByFunc: function (value) {
				this.orderBy = value
				if(this.sequence == 'asc'){
					this.sequence = 'desc'
				}else{
					this.sequence = 'asc'
				}
				sessionStorage.orderBy = this.orderBy
				sessionStorage.sequence = this.sequence
			}
		}
	}
</script>

<style>
	.btnTab{
		width: 120px;
		float: right;
		margin-bottom: 5px;
		margin-right: 5px;
	}

	.btnTab > .vux-button-tab-item{
		font-size: 12px;
	}

	.salesDataDiscoveryGroup > .weui-cells {
		z-index: 999;
		font-size: 17px !important;
	}

	.grid-center {
		display: block;
		text-align: center;
		color: #666;
	}

	.grid-center-name{
		display: block;
		text-align: center;
		color: #43abe3;
	}

	.marketingList {
		margin-top: 46px;
	}

	.marketingList > .weui-grids > .weui-grid {
		padding: 10px 0px;
		text-decoration: none;
		font-size: 12px;
	}

	.memberStatusTitle {
		background-color: lightgoldenrodyellow;
		z-index: 999;
	}

	.memberStatusCell {
		background-color: white;
	}

	.memberStatusGroup > .weui-cells {
		z-index: 999;
	}
</style>